<template>
	<view class="select-container">
		<view @tap.stop="open">
			<view class="select-main">
				<view class="class-name u-line-1 pr10">{{current.value ? current.label : '全部状态'}}</view>
				<u-icon bold color="#555555" size="22rpx" name="arrow-down"></u-icon>
			</view>
		</view>
		<u-picker title="课程状态选择" cancelColor="#999999" confirmColor="#165dff" closeOnClickOverlay keyName="label"
			:show="show" ref="uPicker" :columns="columns" @close="close" @cancel="close" @confirm="confirm"
			@open="open"></u-picker>
	</view>
</template>

<script>
	export default {
		props: {
			value: {
				type: [Number, String],
				default: ''
			}
		},
		data() {
			return {
				show: false,
				current: {},
				columns: [
					[{
						label: '全部状态',
						value: ''
					}, {
						label: '待上课',
						value: 0
					}, {
						label: '已上课',
						value: 1
					}]
				],
				loading: false
			}
		},
		methods: {
			close() {
				this.show = false
			},
			open() {
				this.show = true
			},
			confirm(e) {
				this.current = e.value[0]
				this.$emit('update:value', this.current.value)
				this.$emit('complete', this.current)
				this.close()
			}
		}
	}
</script>
<style lang="scss" scoped>
	.select-container {
		display: inline-block;
	
		.select-main {
			background-color: $u-primary-light;
			display: flex;
			align-items: center;
			width: 100%;
			padding: 12rpx 24rpx;
			border-radius: 8rpx;
			border: 2rpx solid $u-border-color;
		}
	
		.class-name {
			flex: 1;
			// text-align: center;
		}
	}
</style>